﻿using System.Windows;

namespace Lottery.Client.SL.Controls
{
    public partial class EditPassWord
    {
        private bool kxx84AsZ1T;

        public EditPassWord()
        {
            InitializeComponent();
            lbWaiting.Text = "正在接收数据...";
            DataCache.ChildWindowObject = this;
        }

        public void SetTitle(int bflag)
        {
            if (bflag == 0)
            {
                base.Title = "(6714)";
            }
            else
            {
                if (bflag == 1)
                {
                    base.Title = "(6730)";
                }
            }
            base.Show();
        }

        private void Bl48Ld5mOE(object obj, string text)
        {
            btnEditPass.IsEnabled = (true);
            if (string.IsNullOrEmpty(text))
            {
                App.ShowMsg("操作成功！");
                base.DialogResult = true;
                return;
            }
            gridLoading.Visibility = Visibility.Collapsed;
            gridPassWordSet.Visibility = Visibility.Visible;
            App.ShowMsg(text);
        }

        private void TQg8oMV4rG()
        {
            gridLoading.Visibility = Visibility.Visible;
            gridPassWordSet.Visibility = Visibility.Collapsed;
        }

        private void btnEditPass_Click(object sender, RoutedEventArgs e)
        {
            var chgPwdData = new ChgPwdData();
            chgPwdData.OldPassword = tbOldPassWord.Password;
            chgPwdData.NewPassword = tbPassWord.Password;
            if (string.IsNullOrWhiteSpace(chgPwdData.OldPassword) || string.IsNullOrWhiteSpace(chgPwdData.NewPassword))
            {
                App.ShowMsg("(6746)");
                return;
            }
            if (chgPwdData.NewPassword.Length < 6)
            {
                //App.ShowMsg(MsgInfo.chgpwd_c_1);
                App.ShowMsg("密码长度必须大于6位");
                return;
            }
            if (chgPwdData.NewPassword != tbConfirmPassWord.Password)
            {
                // App.ShowMsg(MsgInfo.chgpwd_c_2);
                App.ShowMsg("两次输入的密码不一致");
                /*[chgpwd_c_2, 两次输入的密码不一致]
*/
                return;
            }
            btnEditPass.IsEnabled = (false);
            TQg8oMV4rG();
            //  App.app_client.ChangePasswordCompleted += new ClientControl.RecvCodeEventHandler(this.Bl48Ld5mOE);
            short type = 0;
            if (base.Title.ToString() == "(6762)")
            {
                type = 1;
            }
            // App.app_client.ChangePassword(type, chgPwdData);
        }
    }
}